package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.util.COSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Controller
@Api(tags = "cos文件上传")
@Tag(name = "COSUploadController", description = "文件上传")
@RequestMapping("/cosUpload")
public class COSUploadController {


    @ApiOperation("cos文件上传")
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<String> upload(MultipartFile file) throws IOException {
       return CommonResult.success(COSUtil.uploadFile(file));
    }


}
